package com.lp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lp.properties.AuthorSettings;

@RestController
@SpringBootApplication
public class SpringbootApplication {

	public static void main(String[] args) {
		/* 普通启动方式*/
		//SpringApplication.run(SpringbootApplication.class, args);
		/* 关闭banner的启动方式*/
		SpringApplication application  = new SpringApplication(SpringbootApplication.class);
		application.setBannerMode(Banner.Mode.OFF);
		application.run(args);
	}
	
	@RequestMapping("/")
	public String hello(){
		return "hello springboot";
	}
	
	
	@Value("${book.author}")
	private String bookAuthor;
	@Value("${book.name}")
	private String bookName;
	@RequestMapping("/index1")
	public String index1(){
		return "Book name is:"+bookName+" and book author is:"+bookAuthor;
	}
	
	@Autowired
	private AuthorSettings author;
	@RequestMapping("/index2")
	public String index2(){
		return "author name is:"+author.getName()+" and author age is:"+author.getAge();
	}
}
